// 测试链接：https://www.luogu.com.cn/problem/P1219

#include <bits/stdc++.h>

using namespace std;

int total; // 总解数
int n;
int arr[100]; // 保存一个解

void print()
{
    // 打印前 3 个解
    if(total <= 2)
    {
        for(int i = 1; i <= n; ++i)
        {
            printf("%d ", arr[i]);
        }
        printf("\n");
    }
}

void f(int limit, int col, int left, int right, int i)
{
    if(col == limit)
    {
        print();
        ++total;
        return;
    }

    int ban = col | left | right;
    int candidate = limit & (~ban);
    int place = 0;
    while(candidate != 0)
    {
        place = candidate & (-candidate);
        candidate ^= place;
        arr[i] = log2(place) + 1;
        f(limit, col | place, (left | place) >> 1, (right | place) << 1, i + 1);
    }
}

int main()
{
    scanf("%d", &n);
    int limit = (1 << n) - 1;
    f(limit, 0, 0, 0, 1);
    printf("%d\n", total);

    return 0;
}